#include "STC.h"
int map[1000][1000];
int test_main(int data[1000][1000]) 
{
	// Write your code here
	int kq=0;
	int x;
	int y;
	x=0;
	while(x < 1000)
	{	
		y =0;
		while(y < 1000)
		{	
			y= y+1;
			if(data[x][y]==0) continue;
			int a;
			int b;
			a = x ;
			b = y;
			while( a < 999 && data[a+1][b]==1 && data[a][b-1]==0 && data[a +1][b+1]==0){
				a = a +1 ;
			}
			a = a +1;					
			if( data[a][b]!=1 || data[a][b-1]!=0 || data[a +1][b]!=0) continue;
			while( a < 999 && data[a][b+1]==1 && data[a+1][b+1]==0 && data[a-1][b+1]==0 ){ 
				b = b+1;
			}

			b = b + 1;	
			if( data[a][b]!=1 || data[a +1][b]!=0 || data[a][b+1]!=0) continue;
			while( a >= 1 && data[a - 1][b]==1 && data[a-1][b+1]==0 && data[a-1][b-1]==0 ){ 
				a = a- 1;
			}

			a = a -1;
			if( data[a][b]!=1 || data[a-1][b]!=0 || data[a][b +1]!=0) continue; 							 
			while( b >= 1 && data[a][b-1]==1 && data[a+1][b-1]==0 && data[a-1][b-1]==0){
				b = b- 1;
			}

			b = b -1;		 
			if( a ==x && b==y && data[a-1][b]==0 && data[a][b-1]==0 && data[a+1][b+1]==0){ 
				kq = kq+1;
			}
		}
		x = x +1;
	}
	return kq;
}
void draw_rect(int x, int y, int w, int h, int color)
{
	for (int cx = x; cx <= x + w; cx++)
	{
		map[y][cx] = color;
		map[y + h][cx] = color;
	}
	for (int cy = y; cy <= y + h; cy++)
	{
		map[cy][x] = color;
		map[cy][x + w] = color;
	}
}
void build_map(void)
{
	for (int y = 0; y < 1000; y++)
	{
		int cx = (RandNum(false) % 85) * 10 + 1;
		int cy = (RandNum(false) % 85) * 10 + 1;
		int w = (RandNum(false) % 100) + 50;
		int h = (RandNum(false) % 100) + 50;
		draw_rect(cx, cy, w, h, 1);
		if ((RandNum(false) % 100) != 0)
		{
			draw_rect(cx - 1, cy - 1, w + 2, h + 2, 0);
			draw_rect(cx + 1, cy + 1, w - 2, h - 2, 0);
		}
	}
}
void main(void)
{
	build_map();
	PutInt(test_main(map));
}
